package com.lyandwc.lw_bbs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lyandwc.lw_bbs.dao.UserDao;
import com.lyandwc.lw_bbs.entity.User;
import com.lyandwc.lw_bbs.service.UserService;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserService {

    @Override
    public User findUserByName(String name) {
        return this.baseMapper.selectOne(
                new QueryWrapper<User>().lambda()
                        .eq(User::getUsername, name)
                        .ne(User::getStatus, 1)
        );
    }

    @Override
    public User findAbbrUserById(int id) {
        return this.baseMapper.findAbbrUserById(id);
    }

    @Override
    public User updateCount(int id) {
        this.baseMapper.updateUserCountById(id);
        return this.baseMapper.selectById(id);
    }
}
